package com.example.adminui.controller;

import com.example.adminui.entity.TeamPerformance;
import com.example.adminui.service.TeamPerformanceService;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/team-performances")
public class TeamPerformanceController {
    private final TeamPerformanceService teamPerformanceService;

    public TeamPerformanceController(TeamPerformanceService teamPerformanceService) {
        this.teamPerformanceService = teamPerformanceService;
    }

    @PostMapping
    public void create(@RequestBody TeamPerformance teamPerformance) {
        teamPerformanceService.save(teamPerformance);
    }

    @PutMapping("/{id}")
    public void update(@PathVariable Long id, @RequestBody TeamPerformance teamPerformance) {
        teamPerformance.setId(id);
        teamPerformanceService.updateById(teamPerformance);
    }

    @DeleteMapping("/{id}")
    public void delete(@PathVariable Long id) {
        teamPerformanceService.removeById(id);
    }

    @GetMapping("/{id}")
    public TeamPerformance get(@PathVariable Long id) {
        return teamPerformanceService.getById(id);
    }
}